package com.yhq.spring.spring.conf;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

/**
 * @author hqyin
 * @date 2023/4/13 2:22 下午
 */
//@Component
@Slf4j
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor{
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        log.info("==========>加工beanFactory 1");
        for (String beanName : beanFactory.getBeanDefinitionNames()) {
            if("fruitService".equals(beanName)) {
                BeanDefinition bd = beanFactory.getBeanDefinition(beanName);
                MutablePropertyValues properties = bd.getPropertyValues();
                properties.add("name","苹果");

            }
        }
    }
}
